package io.kiki.stack.netty.util;

import java.util.concurrent.atomic.AtomicInteger;

public class IdGenerator {
    private static final AtomicInteger id = new AtomicInteger(0);

    public static synchronized int nextId() {
        int id = IdGenerator.id.incrementAndGet();
        if (id < 0) {
            IdGenerator.id.set(0);
            id = IdGenerator.id.incrementAndGet();
        }
        return id;
    }

}
